//
//  LTQuestionDetailsViewController.m
//  LearnTeacher
//
//  Created by zyl_macbookpro on 2024/4/22.
//

#import "LTQuestionDetailsViewController.h"
#import "LTHomeworkTableViewCell.h"
#import "LTChooseClassView.h"
#import "LTDatePickerView.h"
@interface LTQuestionDetailsViewController ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic ,strong)UITableView *tableView;

@property(nonatomic ,strong)UIView *tableHeaderView;

@property(nonatomic ,strong)NSArray *data;

@end

@implementation LTQuestionDetailsViewController
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
   
    [self renderNavBarWithBackgroundImage:[UIImage imageWithColor:LTClearColor] backgroundColor:LTClearColor shadowColor:nil textAttributeDic:@{NSForegroundColorAttributeName:rgba(0, 0, 0, 1),NSFontAttributeName:MFontWithSize(17)} enableScrollEdgeAppearance:YES];

}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = rgba(247, 248, 250, 1);
    [self.view addSubview:self.tableView];
    self.title = @"题目详情";
}
- (void)chooseClick:(UIButton *)btn
{
    btn.selected = !btn.selected;
   
}
#pragma mark -UITableViewDelegate,UITableViewDelegate
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    LTHomeworkTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LTHomeworkTableViewCell"];
   // cell.data = self.data[indexPath.row];
   
    return cell;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 12;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 0;
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    return 245;
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 64;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.001;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    return [UIView new];
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{

    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 16, LTScreenWidth,64)];
    headerView.backgroundColor = LTClearColor;
   
    
    UIView *cardView = [[UIView alloc] initWithFrame:CGRectMake(16, 6, LTScreenWidth - 32,52)];
    cardView.backgroundColor = LTWhiteColor;
    [cardView setAllCornersWithCornerRadius:12];
    
    [headerView addSubview:cardView];
    
    UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(16, 18, 18, 17)];
    imgView.image = IMAGENAMED(@"ic_homework_liebiao");
    [cardView addSubview:imgView];
    
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(49, 16,42, 20)];
    titleLabel.font = RFontWithSize(14);
    titleLabel.text = [NSString stringWithFormat:@"%@",@"第一题"];
    [titleLabel setTextAlignment:NSTextAlignmentCenter];
    titleLabel.textColor = LTTextBlack;
    [cardView addSubview:titleLabel];
    
    UILabel *sorceATLabel = [[UILabel alloc] initWithFrame:CGRectMake(LTScreenWidth - 32 - 41 - 52 - 92, 0,56, 52)];
    sorceATLabel.font = RFontWithSize(12);
    sorceATLabel.textColor = LTTextBlack;
    NSString * sorce = [NSString stringWithFormat:@"%@\n%@",@"4.44",@"平均分"];
    NSMutableAttributedString *attS = [[NSMutableAttributedString alloc] initWithString:sorce];
    [attS addAttribute:NSForegroundColorAttributeName value:rgba(102, 102, 102, 1) range:[sorce rangeOfString:@"平均分"]];
    sorceATLabel.attributedText = attS;
    sorceATLabel.numberOfLines = 2;
    [sorceATLabel setTextAlignment:NSTextAlignmentCenter];
    [cardView addSubview:sorceATLabel];
    
    
    UILabel *sorceAllLabel = [[UILabel alloc] initWithFrame:CGRectMake(LTScreenWidth - 32 - 41 - 52, 0,52, 52)];
    sorceAllLabel.numberOfLines = 2;
    sorceAllLabel.font = RFontWithSize(12);
    sorceAllLabel.textColor = LTTextBlack;
    [sorceAllLabel setTextAlignment:NSTextAlignmentCenter];
    NSString *sorceAll = [NSString stringWithFormat:@"%@\n%@",@"4.44",@"题目满分"];
    NSMutableAttributedString *attAll = [[NSMutableAttributedString alloc] initWithString:sorceAll];
    [attAll addAttribute:NSForegroundColorAttributeName value:rgba(102, 102, 102, 1) range:[sorceAll rangeOfString:@"题目满分"]];
    sorceAllLabel.attributedText = attAll;
    [cardView addSubview:sorceAllLabel];
    
    UIButton *btn = ({
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.frame = CGRectMake(LTScreenWidth - 32 - 41, 0, 41, 52);
        
        button.titleLabel.font = RFontWithSize(13);
        [button setImage:[UIImage imageNamed:@"ic_homework_arrow_down_gray"] forState:UIControlStateNormal];
        [button setImage:[UIImage imageNamed:@"ic_homework_arrow_up_gray"] forState:UIControlStateSelected];
        button;
    });
    [cardView addSubview:btn];
    return headerView;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UIViewController *vc = [[UIViewController alloc] initWithClassName:@"LTHomeworkDetailVC"];
   // vc.paraObject = self.data[indexPath.row];
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
    
}

-(UITableView *)tableView{
    if (!_tableView){
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, LTTopBarHeight, LTScreenWidth, LTScreenHeight - LTTopBarHeight) style:UITableViewStyleGrouped];
        [_tableView setDelegate:self];
        [_tableView setDataSource:self];
        _tableView.bounces = NO;
        [_tableView setBackgroundColor:LTClearColor];
        [_tableView setSeparatorColor:LTClearColor];
        [_tableView setTableHeaderView:self.tableHeaderView];
    }
    
    return _tableView;
}
- (UIView *)tableHeaderView
{
    if (!_tableHeaderView) {
        _tableHeaderView =  [[UIView alloc] initWithFrame:CGRectMake(0, 16, LTScreenWidth,38)];
        _tableHeaderView.backgroundColor = LTClearColor;
        
        UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(22, 16,LTScreenWidth - 68 - 16 - 22 - 10, 18)];
        titleLabel.font = SFontWithSize(13);
        titleLabel.text = [NSString stringWithFormat:@"%@",@"Module 1 B卷"];
        [titleLabel setTextAlignment:NSTextAlignmentLeft];
        titleLabel.textColor = LTTextBlack;
        [_tableHeaderView addSubview:titleLabel];
        
        UIButton *btn = ({
            UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
            button.frame = CGRectMake(LTScreenWidth - 68 - 16, 12, 68, 22);
            [button setTitle:@"全部展开" forState:UIControlStateNormal];
            [button setTitleColor:LTTextBlack forState:UIControlStateNormal];
            button.titleLabel.font = RFontWithSize(13);
            
            button;
        });
        [_tableHeaderView addSubview:btn];
    }
    return _tableHeaderView;
}

@end
